<!--
conversation.jinja2.html: Jinja2 template for ConversationWidget
-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Conversation</title>
    <meta name="airunner-theme" content="{{ theme }}">
    <script src="qrc:///qtwebchannel/qwebchannel.js"></script>
    <link id="theme-vars" rel="stylesheet" href="../css/variables-{{ theme }}.css">
    <link id="theme-style" rel="stylesheet" href="../css/theme-{{ theme }}.css">
    <link rel="stylesheet" href="../css/conversation.css">
    <!-- MathJax Configuration -->
    <script>
        window.MathJax = {
            tex: {
                inlineMath: [['$', '$'], ['\\(', '\\)']],
                displayMath: [['$$', '$$'], ['\\[', '\\]']],
                processEscapes: true
            },
            svg: {
                fontCache: 'global'
            },
            startup: {
                ready: () => {
                    console.log('[ConversationWidget] MathJax is ready.');
                    MathJax.startup.defaultReady();
                }
            }
        };
    </script>
    <!-- MathJax Library (local) - use protocol-relative URL to match host/port used by webengine -->
    <script id="MathJax-script" async src="//127.0.0.1:5005/static/mathjax/MathJax-3.2.2/es5/tex-mml-chtml.js"></script>
    <!-- Marked.js for Markdown parsing -->
    <script src="https://cdn.jsdelivr.net/npm/marked@11.1.1/marked.min.js"></script>
</head>
<body>
    <div id="conversation-container">
        <!-- Messages will be rendered here by conversation.js -->
    </div>
    <script src="../js/conversation.js"></script>
    <script>
    // Theme switching logic for webEngineView
    function setTheme(theme) {
        document.getElementById('theme-vars').href = `../css/variables-${theme}.css`;
        document.getElementById('theme-style').href = `../css/theme-${theme}.css`;
        window.currentTheme = theme;
    }
    window.setTheme = setTheme;
    document.addEventListener('DOMContentLoaded', function () {
        let theme = document.querySelector('meta[name="airunner-theme"]')?.content || window.currentTheme || 'light';
        window.currentTheme = theme;
        setTheme(theme);
    });
    </script>
</body>
</html>
